package com.zeei.ems.base.util;

import com.zeei.ems.base.security.bo.SessionUserInfo;
import com.zeei.ems.base.vo.UserVO;
import org.springframework.security.core.context.SecurityContextHolder;

public class SessionHelper {

    public static UserVO getUser(){
        return getSessionUserInfo().getUser();
    }

    public static String getUserName(){
        return getSessionUserInfo().getUser().getUsername();
    }

    public static Integer getContactUserId(){
        return getSessionUserInfo().getUser().getContactUserId();
    }

    public static Integer getUserId(){
        return getSessionUserInfo().getUser().getUserid();
    }

    public static String getLoginName(){
        return getSessionUserInfo().getUser().getLoginname();
    }

    private static SessionUserInfo getSessionUserInfo(){
        SessionUserInfo sessionUserInfo = (SessionUserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return sessionUserInfo;
    }

}
